﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using YSC_Core.BLL.Domain.ViewModels;
using YSC_Services.BLL.Services.Interfaces;

namespace YSC_Backstage_Web.Controllers
{
    /// <summary>
    /// 系统菜单
    /// </summary>
    public class MeunController : Controller
    {
        private IUserBackstageServices _pro;
        public MeunController(IUserBackstageServices pro)
        {
            this._pro = pro;
        }


        /// <summary>
        ///  菜单列表
        /// </summary>
        /// <returns></returns>
        public IActionResult List()
        {
            return View();
        }

        /// <summary>
        /// 菜单添加
        /// </summary>
        /// <returns></returns>
        public IActionResult Add()
        {
            return View();
        }

        /// <summary>
        /// 菜单列表
        /// </summary>
        /// <returns></returns>
        public JsonResult GetMenuAll()
        {
            var ret = _pro.GetMenuAll();
            return Json(ret);
        }

        /// <summary>
        /// 菜单新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult AddMenu([FromBody] MenuModel model)
        {
            var ret = _pro.AddMenu(model);
            return Json(ret);
        }

        /// <summary>
        /// 一级菜单
        /// </summary>
        /// <returns></returns>
        public JsonResult ToMenu()
        {
            var ret = _pro.TopMenu();
            return Json(ret);
        }
    }
}